﻿using Shop.Entity;
using System;
using System.Collections.Generic;

namespace Shop.Interface
{
    public interface IBase
    {
        /// <summary>
        /// 新增
        /// </summary>
        /// <param name="t">保存对象</param>
        /// <param name="user">操作人</param>
        /// <returns>返回成功或失败</returns>
        bool Insert<TInsert>(TInsert t, ComUser user) where TInsert:AddEntity,new();

        /// <summary>
        /// 更新
        /// </summary>
        /// <param name="t">保存对象</param>
        /// <param name="user">操作人</param>
        /// <returns>返回成功或失败</returns>
        bool Update<TUpdate>(TUpdate t, ComUser user) where TUpdate : UpdateEntity, new();

        /// <summary>
        /// 删除
        /// </summary>
        /// <param name="id">唯一键</param>
        /// <param name="user">操作人</param>
        /// <param name="isPhysical">是否物理删除</param>
        /// <returns>返回成功或失败</returns>
        bool Delete<TUpdate>(dynamic id, ComUser user,bool isPhysical=false) where TUpdate:UpdateEntity,new();

        /// <summary>
        /// 删除【批量】
        /// </summary>
        /// <param name="id">唯一键</param>
        /// <param name="user">操作人</param>
        /// <param name="isPhysical">是否物理删除</param>
        /// <returns>返回成功或失败</returns>
        bool Delete<TUpdate>(List<dynamic> id, ComUser user, bool isPhysical = false) where TUpdate : UpdateEntity, new();

        /// <summary>
        /// 获取单个
        /// </summary>
        /// <typeparam name="T">返回类型</typeparam>
        /// <param name="id">主键</param>
        /// <returns></returns>
        T Find<T>(dynamic id) where T : BaseEntity, new();

        /// <summary>
        /// 获取所有 未删除的数据
        /// </summary>
        /// <typeparam name="T">返回类型</typeparam>
        /// <returns></returns>
        List<T> GetAll<T>() where T : BaseEntity, new();
    }
}
